#include <iostream>
#include <cmath>

using namespace std;
typedef double NUM;

int main()
{
	NUM result = 0,result_n = 0,t = 0;

	for(double p=1.0; p<=1000.0; p++)
	{
		NUM t = 0;
		for(NUM a=1,z=p/2; a<z; a++)
			for(NUM b=1,zz=2*p/3; a+b<zz; b++)
				if(sqrt(a*a+b*b) + a+b == p)
					t++;

		if(t > result_n)
		{
			result = p;
			result_n = t;
		}

	}

	cout << result << " -> " << result_n << endl;
	return 0;
}


/*
If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.
{20,48,52}, {24,45,51}, {30,40,50}
For which value of p <=  1000, is the number of solutions maximised?
*/
